package top.szhome.system.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import top.szhome.framework.core.tools.support.Resp;
import top.szhome.framework.starter.db.support.SimpleController;
import top.szhome.system.convert.RoleConverter;
import top.szhome.system.dto.RoleDTO;
import top.szhome.system.entity.Role;
import top.szhome.system.qry.RoleQry;
import top.szhome.system.service.RoleService;
import top.szhome.system.vo.RoleVO;

import java.util.List;

/**
 * 角色 接口实现
 *
 * @author 唐加利
 * @date 2023/07/31
 **/
@AllArgsConstructor
@RestController
@RequestMapping("/system/role")
@Tag(name = "角色")
public class RoleController extends SimpleController<RoleService, RoleConverter, RoleQry, RoleDTO, Role, RoleVO> {

    /**
     * 角色分配菜单
     *
     * @param roleIds    角色列表
     * @param menuIds   菜单列表
     * @return
     */
    @Operation(summary = "分配角色菜单", description = "给指定角色分配菜单权限")
    @PostMapping("grant-menus")
    public Resp grant(@RequestParam List<Long> roleIds, @RequestParam List<Long> menuIds) {
        getBaseService().grantMenus(roleIds, menuIds);
        return Resp.success();
    }
    
}
